﻿<u:HeaderedToolItem x:Class="WickedFlame.VecDraw.Plugins.MainColorSelector"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ctrl="clr-namespace:WickedFlame.VecDraw.Base.Controls;assembly=VecDraw.Base"
    xmlns:u="clr-namespace:WickedFlame.Util.Controls;assembly=VecDraw.Util"
    xmlns:t="clr-namespace:WickedFlame.Core.Tools;assembly=VecDraw.Core"
    xmlns:cv="clr-namespace:WickedFlame.Util.Converters;assembly=VecDraw.Util"
    x:Name="this"
    Title="Color" Icon="/VecDraw.Resources;component/Images/VecDraw.Icon.ColorCircle.png"
    Loaded="Window_Loaded" IsExpanded="False" Foreground="WhiteSmoke" FontSize="10" FontWeight="Heavy">
    
    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/ControlTemplates.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>


        <Grid Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5" >
            <Grid.Resources>
                <Image Source="/VecDraw.Resources;component/Images/VecDraw.ColorSwitch.Square.png" x:Key="swatchimage"/>
            </Grid.Resources>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!--MouseDown="Grid_MouseDown"-->
            <!--<Image Grid.Column="0" x:Name="ColorImage"  
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       SnapsToDevicePixels="True"
                   Height="210"
                   Width="210"
                       Source="/VecDraw.Resources;component/Images/VecDraw.ColorSwitch.Square.png"/>
            <Canvas Grid.Column="1" x:Name="ColorPalete"
                       Background="Transparent"
                    Width="{Binding ElementName=ColorImage, Path=Width}"
                    Height="{Binding ElementName=ColorImage, Path=Height}"
                       MouseLeftButtonUp="ColorPalete_MouseLeftUp"
                       MouseRightButtonUp="ColorPalete_MouseRightUp">
                <Ellipse x:Name="ellipsePixel" Width="5" 
                       Height="5" Stroke="Black" Fill="White" 
                       Canvas.Left="0" Canvas.Top="0"/>
            </Canvas>-->

            <ctrl:ColorSwatch Grid.Row="1" SelectedColor="{Binding ElementName=this, Path=SelectedColor}" SwatchImage="{StaticResource swatchimage}"/>

        </Grid>


        <Grid Grid.Row="1">
            <Grid.Resources>
                <cv:BrushToColorConverter x:Key="brushtocolor"/>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Border Grid.Column="0" Width="40" Height="40" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Margin="5,2,2,2" CornerRadius="2">
                <Border.Background>
                    <SolidColorBrush Color="{Binding ElementName=this, Path=SelectedColor}"/>
                </Border.Background>
            </Border>
            <ctrl:ColorSwitch Grid.Column="1" Width="40" Height="40" Margin="5,2,2,2" Name="colorSelector" DataContext="{x:Static t:ShapePropertySettings.Settings}" SelectedFillColor="{Binding Fill, Converter={StaticResource brushtocolor}}" SelectedStrokeColor="{Binding Stroke, Converter={StaticResource brushtocolor}}"/>

        </Grid>

        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="35"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!--<Grid Grid.Row="0" Grid.ColumnSpan="3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" Text="RGB"/>
                <Rectangle Grid.Column="1" Fill="Gray" Height="1" Margin="5,0,5,0" VerticalAlignment="Center"/>
            </Grid>-->

            <TextBlock Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" Text="R"/>
            <TextBlock Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" Text="G"/>
            <TextBlock Grid.Row="3" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" Text="B"/>

            <!--<Grid Grid.Row="4" Grid.ColumnSpan="3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" Text="Alpha"/>
                <Rectangle Grid.Column="1" Fill="Gray" Height="1" Margin="5,0,5,0" VerticalAlignment="Center"/>
            </Grid>-->

            <TextBlock Grid.Row="5" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" Text="A"/>


            <Grid Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="20,0,3,0">
                <Border x:Name="rBorder" BorderBrush="Black" BorderThickness="1" CornerRadius="2" Height="5" />
                <Slider x:Name="rColorSlider" Orientation="Horizontal" Minimum="0" MinHeight="5" TickPlacement="None" Maximum="255" SmallChange="1" LargeChange="25" VerticalAlignment="Center" Value="255" ValueChanged="rColorSlider_ValueChanged"/>
            </Grid>

            <Grid Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="20,0,3,0">
                <Border x:Name="gBorder" BorderBrush="Black" BorderThickness="1" CornerRadius="2" Height="5"/>
                <Slider x:Name="gColorSlider" Orientation="Horizontal" Minimum="0" Maximum="255" TickPlacement="None" SmallChange="1" LargeChange="25" VerticalAlignment="Center" Value="255" ValueChanged="gColorSlider_ValueChanged" AutoToolTipPlacement="None" />
            </Grid>

            <Grid Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="20,0,3,0">
                <Border x:Name="bBorder" BorderBrush="Black" BorderThickness="1" CornerRadius="2" Height="5" />
                <Slider x:Name="bColorSlider" Orientation="Horizontal" Minimum="0" Maximum="255" TickPlacement="None" SmallChange="1" LargeChange="25" VerticalAlignment="Center" Value="255" ValueChanged="bColorSlider_ValueChanged"/>
            </Grid>

            <Grid Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" Margin="20,0,3,0">
                <Border x:Name="AlphaBorder" BorderBrush="Black" BorderThickness="1" CornerRadius="2" Height="5" />
                <Slider x:Name="AlphaSlider" Orientation="Horizontal" Minimum="0" Maximum="255" SmallChange="1" LargeChange="25" VerticalAlignment="Center" Value="255" ValueChanged="AlphaSlider_ValueChanged" VerticalContentAlignment="Top" />
            </Grid>


            <TextBox Grid.Row="1" Grid.Column="2" Name="txtColorR" Margin="5,1,5,1" Padding="1" FontWeight="Normal" TextChanged="txtColor_TextChanged"/>
            <TextBox Grid.Row="2" Grid.Column="2" Name="txtColorG" Margin="5,1,5,1" Padding="1" FontWeight="Normal" TextChanged="txtColor_TextChanged"/>
            <TextBox Grid.Row="3" Grid.Column="2" Name="txtColorB" Margin="5,1,5,1" Padding="1" FontWeight="Normal" TextChanged="txtColor_TextChanged"/>
            <TextBox Grid.Row="5" Grid.Column="2" Name="txtColorA" Margin="5,1,5,1" Padding="1" FontWeight="Normal" TextChanged="txtColor_TextChanged"/>

        </Grid>

        <Grid Grid.Row="3">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Grid>

                    <StackPanel Orientation="Horizontal" Margin="3">
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="#FFFFFFFF" MouseUp="TransparentSelector_MouseUp">
                            <Path Data="M10,0 L 0,10" Stroke="Red" StrokeThickness="2" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2"/>
                        </Border>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="#FFFFFFFF" MouseUp="QuickColorSelector_MouseUp"/>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="#FF000000" MouseUp="QuickColorSelector_MouseUp"/>

                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="Gray" MouseUp="QuickColorSelector_MouseUp"/>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="LightGray" MouseUp="QuickColorSelector_MouseUp"/>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="Red" MouseUp="QuickColorSelector_MouseUp"/>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="Green" MouseUp="QuickColorSelector_MouseUp"/>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="Blue" MouseUp="QuickColorSelector_MouseUp"/>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="Yellow" MouseUp="QuickColorSelector_MouseUp"/>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="Brown" MouseUp="QuickColorSelector_MouseUp"/>
                       
                         <!--<Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="#FF000000" MouseUp="QuickColorSelector_MouseUp"/>
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" Margin="2" Height="12" Width="12" Background="#FF000000" MouseUp="QuickColorSelector_MouseUp"/>-->
                    </StackPanel>
                </Grid>

                <!--<Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20"/>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <StackPanel Orientation="Horizontal" Grid.Column="1" Margin="0,6,0,0">

                        <Border Name="transparentBorder" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="1" Height="12" Width="12">
                            <Image Source="/VecDraw.Resources;component/Images/VecDraw.Icon.SymbolTransparen.png" MouseEnter="Transparent_MouseEnter" MouseLeave="Transparent_MouseLeave" MouseLeftButtonUp="Transparent_MouseLeftButtonUp" />
                        </Border>

                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Black" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp" />
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Gray" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="LightGray" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Red" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Green" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Yellow" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Black" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Column="1" Margin="0,18,0,0">
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Transparent"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="White" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="WhiteSmoke" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Black" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Black" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="YellowGreen" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="LightSalmon" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                        <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Height="12" Fill="Black" MouseEnter="ColorRect_MouseEnter" MouseLeave="ColorRect_MouseLeave" MouseLeftButtonUp="ColorRect_MouseLeftButtonUp" MouseRightButtonUp="ColorRect_MouseRightButtonUp"/>
                    </StackPanel>
                </Grid>-->
            </Grid>

        </Grid>
    </Grid>
</u:HeaderedToolItem>
